﻿using System;
using FU.Capstones.IMS.Web.Common;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.EventArgs;

namespace FU.Capstones.IMS.Web.Silverlight.Models
{
    public class ExportProductOrderModel: ModelBase
    {
        public ExportProductOrderModel()
        {
            client.InsertOrderCompleted += DoInsertOrderCompleted;
            client.GetWarehouseCollectionCompleted += DoGetWarehouseCollectionCompleted;
            client.GetEmployeeCollectionCompleted +=DoGetEmployeeCollectionCompleted;
            client.GetContactCollectionCompleted += DoGetContactCollectionCompleted;
            
        }

        #region GetContactCollection

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Contact>> GetContactCollectionCompleted;
        void DoGetContactCollectionCompleted(object sender, CollectionFeedbackCompletedEventArgs<Contact> e)
        {
            if (GetContactCollectionCompleted != null)
            {
                GetContactCollectionCompleted(sender, e);
            }
        }
        public int GetContactCollectionAsync(bool isShowAll)
        {
            client.GetContactCollectionAsync(isShowAll);
            return WebConstants.MagicNumer;
        }

        #endregion

        #region GetEmployeeCollection

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Employee>> GetEmployeeCollectionCompleted;
        void DoGetEmployeeCollectionCompleted(object sender, CollectionFeedbackCompletedEventArgs<Employee> e)
        {
            if (GetEmployeeCollectionCompleted != null)
            {
                GetEmployeeCollectionCompleted(sender, e);
            }
        }
        public int GetEmployeeCollectionAsync(bool isShowAll)
        {
            client.GetEmployeeCollectionAsync(isShowAll);
            return WebConstants.MagicNumer;
        }

        #endregion


        #region GetCollectionWarehouse

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Warehouse>> GetWarehouseCollectionCompleted;
        void DoGetWarehouseCollectionCompleted(object sender, CollectionFeedbackCompletedEventArgs<Warehouse> e)
        {
            if (GetWarehouseCollectionCompleted != null)
            {
                GetWarehouseCollectionCompleted(sender, e);
            }
        }
        public int GetWarehouseCollectionAsync(bool isShowAll)
        {
            client.GetWarehouseCollectionAsync(isShowAll);
            return WebConstants.MagicNumer;
        }

        #endregion


        #region InsertOrder

        public event EventHandler<SingleFeedbackCompletedEventArgs<int>> InsertOrderCompleted;
        void DoInsertOrderCompleted(object sender, SingleFeedbackCompletedEventArgs<int> e)
        {
            if (InsertOrderCompleted != null)
            {
                InsertOrderCompleted(sender, e);
            }
        }

        public int InsertOrderAsync(Order newOrder)
        {
            client.InsertOrderAsync(newOrder);
            return WebConstants.MagicNumer;
        }

        #endregion
    }
}
